package com.lhd.weibo.service.impl;

import com.lhd.weibo.mapper.CommentMapper;
import com.lhd.weibo.pojo.dto.CommentDTO;
import com.lhd.weibo.pojo.entity.Comment;
import com.lhd.weibo.pojo.vo.CommentVO;
import com.lhd.weibo.service.CommentService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author lhd
 * date 2024/5/17
 * @apiNote
 */
@Service
public class CommentServiceimpl implements CommentService {
    @Autowired
    private CommentMapper commentMapper;

    @Override
    public void addNewComment(CommentDTO commentDTO) {
        Comment comment = new Comment();
        BeanUtils.copyProperties(commentDTO,comment);
        comment.setCreated(new Date());
        commentMapper.addNewComment(comment);
    }

    @Override
    public List<CommentVO> listByWeiboId(Long id) {
        return commentMapper.listByWeiboId(id);
    }
}
